//
//  HomeGoodsListCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/8.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "HomeGoodsListCell.h"

@interface HomeGoodsListCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UIImageView *rightImageView;
@property (weak, nonatomic) IBOutlet UILabel *leftTopLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightTopLabel;
@property (weak, nonatomic) IBOutlet UILabel *leftBottomLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightBottomLabel;
@property (weak, nonatomic) IBOutlet UIButton *leftJumpBtn;
@property (weak, nonatomic) IBOutlet UIButton *rightJumBtn;
@property (weak, nonatomic) IBOutlet UIView *leftProgressView;
@property (weak, nonatomic) IBOutlet UIView *leftProgressTopView;
@property (weak, nonatomic) IBOutlet UIView *rightProgressView;
@property (weak, nonatomic) IBOutlet UIView *rightProgressTopView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftProgressW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightProgressW;
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;

@end

@implementation HomeGoodsListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.leftTopLabel.font = MYFONT(13);
    self.rightTopLabel.font = MYFONT(13);
    self.leftBottomLabel.font = MYFONT(13);
    self.rightBottomLabel.font = MYFONT(13);
    
    self.leftProgressView.backgroundColor = lineGray;
    self.rightProgressView.backgroundColor = lineGray;
    self.leftProgressTopView.backgroundColor = themeColor;
    self.rightProgressTopView.backgroundColor = themeColor;
    
    self.leftProgressView.layer.cornerRadius = 3;
    self.leftProgressView.layer.masksToBounds = YES;
    
    self.rightProgressView.layer.cornerRadius = 3;
    self.rightProgressView.layer.masksToBounds = YES;
    
    self.leftJumpBtn.layer.cornerRadius = 20;
    self.leftJumpBtn.layer.masksToBounds = YES;
    
    self.rightJumBtn.layer.cornerRadius = 20;
    self.rightJumBtn.layer.masksToBounds = YES;
    
    self.leftJumpBtn.titleLabel.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:19];
    
    self.rightJumBtn.titleLabel.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:19];



    // Initialization code
}


- (void)setModels:(NSArray<GoodsInfoModel *> *)models{
    _models = models;
    
    if (_models.count == 1) {
        
        self.rightBtn.backgroundColor = lineGray;
        self.rightBtn.userInteractionEnabled = NO;
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:_models.firstObject.goods_image]];
        
        self.leftTopLabel.text = _models.firstObject.goods_name;
        
    } else {
        
        self.rightBtn.backgroundColor = [UIColor clearColor];
        self.rightBtn.userInteractionEnabled = YES;
        
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:_models.firstObject.goods_image]];

        
        [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:_models.lastObject.goods_image]];
        
        self.leftTopLabel.text = _models.firstObject.goods_name;
        
        self.rightTopLabel.text = _models.lastObject.goods_name;


    }
    
    
    
    
}


- (IBAction)leftBtnDidClick:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(homeGoodsBtnDidClickWithModel:)]) {
        [self.delegate homeGoodsBtnDidClickWithModel:nil];
    }
}
- (IBAction)rightBtnDidClick:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(homeGoodsBtnDidClickWithModel:)]) {
        [self.delegate homeGoodsBtnDidClickWithModel:nil];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
